/**
* @description: 1464. 数组中两元素的最大乘积
* @author hewei
* @date 2022/8/26 15:12
* @version 1.0
*/

public class MaxProduct3 {

    public int maxProduct(int[] nums) {
        int ans = 0;
        int max = nums[0];
        for (int i = 1; i < nums.length; i++) {
            ans = Math.max((max - 1) * (nums[i] - 1), ans);
            max = Math.max(max, nums[i]);
        }
        return ans;
    }
}
